<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('书籍列表')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="role-form">
					<div class="select-list">
						<ul>
							<li>
								书籍名称：<input type="text" name="name"/>
							</li>
							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<label>图书类型：</label>
								<select name="typeId">
									<option value="">--请选择图书类型--</option>
									<option   th:each="libraryType:${libraryTypes}" th:value="${libraryType.typeId}" th:text="${libraryType.tyname}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
		
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="library:book:add">
	                <i class="fa fa-plus"></i> 新增
	            </a>
	            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="library:book:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>
				<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="library:book:remove">
		            <i class="fa fa-remove"></i> 删除
		        </a>
		        <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="library:book:export">
		            <i class="fa fa-download"></i> 导出
		        </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('library:book:edit')}]];
		var removeFlag = [[${@permission.hasPermi('library:book:remove')}]];
		var prefix = ctx + "admin/library/book";


		$(function() {
		    var options = {
		        url: prefix + "/list",
		        createUrl: prefix + "/add",
		        updateUrl: prefix + "/edit/{id}",
		        removeUrl: prefix + "/remove",
		        exportUrl: prefix + "/export",
		        sortName: "a.create_time",
		        modalName: "图书书籍",
				showPageGo: true,
		        columns: [{
		            checkbox: true
		        },
				{
						field: 'bookId',
						title: '书籍序号',
						visible:false
					},
		        {
		            field: 'isbn',
		            title: '书籍编号'
		        },
		        {
		            field: 'name',
		            title: '书籍名称',
		            sortable: true
		        },
		        {
		            field: 'author',
		            title: '书籍作者',
		            sortable: true
		        },
				{
						field: 'publish',
						title: '书籍出版社'
				},
				{
						field: 'introduction',
						title: '书籍简介'
				},
				{
						field: 'language',
						title: '书籍语言'
				},
				{
						field: 'price',
						title: '书籍价格'
				},
				{
						field: 'publishDate',
						title: '书籍出版日期'
				},
				{
						field: 'libraryType.tyname',
						title: '书籍类型'
				},
				{
						field: 'count',
						title: '书籍数量'
				},
		        {
		            field: 'createTime',
		            title: '创建时间',
		            sortable: true,
					sortName: 'a.create_time'
		        },
				{
						field: 'updateTime',
						title: '修改时间',
						sortable: true,
						sortName: 'a.update_time'
				},
		        {
		            title: '操作',
		            // align: 'center',
		            formatter: function(value, row, index) {
						    var actions = [];
						    actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.bookId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
						    actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.bookId + '\')"><i class="fa fa-remove"></i>删除</a> ');
							return actions.join('');
		            }
		        }]
		    };
		    $.table.init(options);
		});
		/* 查询表格选择行数据值 */
		function getSelections(){
			var data = $("#" + table.options.id).bootstrapTable('getSelections');
			return data;
		}
	</script>
</body>
</html>